package com.lokyiu.mybible.domain;

import java.util.List;

public class BibleBook {

	private String name;
	private String url;

	// List<Chapter> is a Java feature called Generics. List is a built-in Java
	// class that stores
	// a collection of objects. List<Chapter> forces the collection to only
	// contain Chapter objects.
	private List<Chapter> chapters;

	/**
	 * This is called a constructor. A constructor is used to create objects
	 * from a class. For example, a BibleBook object can be created like this:
	 * BibleBook genesis = new BibleBook("Genesis"); Of course, this statement
	 * will only create Genesis with an empty list of chapters.
	 * 
	 * @param name
	 * @param chapters
	 */
	public BibleBook(String name, String url) {
		this.name = name;
		this.url = url;
	}

	public String getName() {
		return this.name;
	}

	public String getUrl() {
		return this.url;
	}

	@Override
	public boolean equals(Object obj) {
		BibleBook objToCompare = (BibleBook) obj;
		boolean urlCompare = this.url == null || objToCompare.getUrl() == null ? true
				: this.url.equals(objToCompare.getUrl());
		
//		boolean urlCompare = false;
//		if (this.url == null || objToCompare.getUrl() == null) {
//			urlCompare = true;
//		} else {
//			urlCompare = this.url.equals(objToCompare.getUrl());
//		}
		return this.name.equals(objToCompare.getName()) && urlCompare;
	}

	@Override
	public String toString() {
		return "name:" + name + " url:" + url;
	}

	// Sorry this method shouldn't be here... forgot to delete it
	// public List<BibleBook> getBooks() {
	// //TODO do not understand
	// return null;
	// }
	//
	/**
	 * Return the collection of chapters for this BibleBook.
	 * 
	 * @return
	 */
	public List<Chapter> getChapters() {
		// TODO do not understand
		return this.chapters;
	}

	public void setChapters(List<Chapter> bibleBook) {
		// TODO finish this method. Clue: this method stores what the
		// getChapters() method returns
		this.chapters = bibleBook;
	}
}
